import i18n from "i18next";
import { initReactI18next } from "react-i18next";

import enTranslation from "./en/translation.json";
import zhTranslation from "./zh/translation.json";
function Initi18() {
  let language = localStorage.getItem("wewin-language");
  if (!language) {
    language = "zh";
    localStorage.setItem("wewin-language", "zh");
  }
  i18n.use(initReactI18next).init({
    resources: {
      en: {
        translation: enTranslation,
      },
      zh: {
        translation: zhTranslation,
      },
    },
    lng: language, // 默认语言
    fallbackLng: "zh", // 当当前语言的翻译缺失时回退到该语言
    interpolation: {
      escapeValue: false, // react已经安全了
    },
  });
}
export default Initi18;
